// 1.0 导入vue核心包
import Vue from 'vue';

//导入vue-router并使用
import vueRouter from 'vue-router';
Vue.use(vueRouter);

//导入格式化日期的moment包
import moment from 'moment';

// 2.0 导入App.vue的vue对象
import App from './App.vue';

//导入mint-ui并使用
import Mint from 'mint-ui';
import 'mint-ui/lib/style.min.css'
Vue.use(Mint);

//导入vue-resource包用来请求ajax数据
import Rsc from "vue-resource";
Vue.use(Rsc);

//导入Muicss文件
import '../../statics/mui/css/mui.css';

//导入图片预览插件
import VuePreview from 'vue-preview'
Vue.use(VuePreview)

//导入自定义的组件
import Home from '../components/Home.vue';
import goodslist from '../components/goods/goodslist.vue';
import goodsinfo from '../components/goods/goodsinfo.vue';
import newslist from '../components/news/newslist.vue';
import newsinfo from '../components/news/newsinfo.vue';
import photolist from '../components/photo/photolist.vue';
import photoinfo from '../components/photo/photoinfo.vue';
import goodsdesc from '../components/goods/goodsdesc.vue';
import goodscomment from '../components/goods/goodscomment.vue';
import shopcar from '../components/shopcar/shopcar.vue'


//初始化路由器
var router = new vueRouter({
	linkActiveClass: "mui-active",
	routes: [{
			path: "/",
			redirect: "/Home"
		},

		{ //主页
			path: "/Home",
			component: Home
		},

		{ //资讯列表
			path: "/news/newslist",
			component: newslist
		},

		{ //资讯详情组件
			path: "/news/newsinfo/:id",
			component: newsinfo
		},

		{ //图片展示组件
			path: "/photo/photolist",
			component: photolist
		},

		{ //图片详情组件
			path: "/photo/photoinfo/:id",
			component: photoinfo
		},

		{ //商品列表组件
			path: "/goods/goodslist",
			component: goodslist
		},

		{ //商品详情组件
			path: "/goods/goodsinfo/:id",
			component: goodsinfo
		},

		{ //商品描述组件
			path: "/goods/goodsdesc/:id",
			component: goodsdesc
		},

		{ //商品评论组件
			path: "/goods/goodscomment/:id",
			component: goodscomment
		},

		{ //购物车组件
			path: "/shopcar/shopcar",
			component: shopcar
		}

	]
});


//导入全局css样式文件
import "../../statics/css/site.css"

//  利用Vue实例对象进行解析渲染
new Vue({
	el: '#app',
	router,
	// render:function(create){create(App)} //es5的写法
	render: c => c(App)
});

//注册Vue的全局filter方法
Vue.filter("datefmt", function (input, str) {
	return moment(input).format(str)
})